load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:common_settings.bzl", "string_setting")
load(
    ":transition.bzl",
    "TRANSITIONED_GO_SETTING_KEYS",
)

exports_files(["library.bzl"])

[
    string_setting(
        name = "original_" + setting.split(":")[1],
        build_setting_default = "",
        visibility = ["//visibility:private"],
    )
    for setting in TRANSITIONED_GO_SETTING_KEYS
]

filegroup(
    name = "all_rules",
    srcs = glob(["**/*.bzl"]),
    visibility = ["//visibility:public"],
)

filegroup(
    name = "all_files",
    testonly = True,
    srcs = glob(["**"]),
    visibility = ["//visibility:public"],
)

bzl_library(
    name = "binary",
    srcs = ["binary.bzl"],
    visibility = [
        "//docs:__subpackages__",
        "//go:__subpackages__",
    ],
    deps = [
        "//go/private:common",
        "//go/private:context",
        "//go/private:mode",
        "//go/private:providers",
        "//go/private:rpath",
        "//go/private/rules:transition",
    ],
)

bzl_library(
    name = "cgo",
    srcs = ["cgo.bzl"],
    visibility = ["//go:__subpackages__"],
    deps = [
        "//go/private:common",
        "//go/private:mode",
    ],  # keep
)

bzl_library(
    name = "info",
    srcs = ["info.bzl"],
    visibility = ["//go:__subpackages__"],
    deps = ["//go/private:context"],
)

bzl_library(
    name = "library",
    srcs = ["library.bzl"],
    visibility = [
        "//docs:__subpackages__",
        "//go:__subpackages__",
    ],
    deps = [
        "//go/private:common",
        "//go/private:context",
        "//go/private:providers",
    ],
)

bzl_library(
    name = "nogo",
    srcs = ["nogo.bzl"],
    visibility = ["//go:__subpackages__"],
    deps = [
        "//go/private:context",
        "//go/private:providers",
        "//go/private/rules:transition",
    ],
)

bzl_library(
    name = "sdk",
    srcs = ["sdk.bzl"],
    visibility = ["//go:__subpackages__"],
    deps = ["//go/private:providers"],
)

bzl_library(
    name = "source",
    srcs = ["source.bzl"],
    visibility = [
        "//docs:__subpackages__",
        "//go:__subpackages__",
    ],
    deps = [
        "//go/private:context",
        "//go/private:providers",
    ],
)

bzl_library(
    name = "stdlib",
    srcs = ["stdlib.bzl"],
    visibility = ["//go:__subpackages__"],
    deps = [
        "//go/private:context",
        "//go/private:providers",
    ],
)

bzl_library(
    name = "test",
    srcs = ["test.bzl"],
    visibility = [
        "//docs:__subpackages__",
        "//go:__subpackages__",
    ],
    deps = [
        "//go/private:common",
        "//go/private:context",
        "//go/private:mode",
        "//go/private:providers",
        "//go/private/rules:binary",
        "//go/private/rules:transition",
        "@bazel_skylib//lib:structs",
    ],
)

bzl_library(
    name = "transition",
    srcs = ["transition.bzl"],
    visibility = [
        "//go:__subpackages__",
        "//proto:__pkg__",
    ],
    deps = [
        "//go/private:mode",
        "//go/private:platforms",
        "//go/private:providers",
    ],
)

bzl_library(
    name = "cross",
    srcs = ["cross.bzl"],
    visibility = [
        "//docs:__subpackages__",
        "//go:__subpackages__",
    ],
    deps = [
        "//go/private:providers",
        "//go/private/rules:transition",
    ],
)

bzl_library(
    name = "wrappers",
    srcs = ["wrappers.bzl"],
    visibility = [
        "//extras:__pkg__",
        "//go:__subpackages__",
    ],
    deps = [
        "//go/private/rules:binary",
        "//go/private/rules:cgo",
        "//go/private/rules:cross",
        "//go/private/rules:library",
        "//go/private/rules:test",
        "//go/private/rules:transition",
    ],
)
